//---------------------------------------------------------------------------
//
//                 __________                                      
//    _____   __ __\______   \_____  _______  ______  ____ _______ 
//   /     \ |  |  \|     ___/\__  \ \_  __ \/  ___/_/ __ \\_  __ \ 
//  |  Y Y  \|  |  /|    |     / __ \_|  | \/\___ \ \  ___/ |  | \/
//  |__|_|  /|____/ |____|    (____  /|__|  /____  > \___  >|__|   
//        \/                       \/            \/      \/        
//  (C) 2011 Ingo Berg
//
//  example1.cpp - using the parser as a static library
//
//---------------------------------------------------------------------------

#ifndef PARSERCALC_HPP
#define PARSERCALC_HPP

#include "muParserTest.h"

#if defined(_WIN32) && defined(_DEBUG)
  #define _CRTDBG_MAP_ALLOC
  #include <stdlib.h>
  #include <crtdbg.h>
  #define CREATE_LEAKAGE_REPORT
#endif

#if defined( USINGDLL ) && defined( _WIN32 )
#error This sample can be used only with STATIC builds of muParser (on win32)
#endif

/** \brief This macro will enable mathematical constants like M_PI. */
#define _USE_MATH_DEFINES		

#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <locale>
#include <limits>
#include <ios> 
#include <iomanip>
#include <numeric>

#include "muParser.h"
#include "Specimen.hpp"
#include "EvalFunction.hpp"
#include "ProportionalEnv.hpp"

using namespace std;
using namespace mu;

/******************************************************************************************/

/********************************IT ALL HAVE TO BE HERE************************************/

/*****************************************SORRY********************************************/

#if defined(CREATE_LEAKAGE_REPORT)

// Dumping memory leaks in the destructor of the static guard
// guarantees i won't get false positives from the ParserErrorMsg 
// class wich is a singleton with a static instance.
struct DumpLeaks
{
 ~DumpLeaks()
  {
    _CrtDumpMemoryLeaks();
  }
} static LeakDumper;

#endif



/*##########################################################################################################*/
/*##########################################################################################################*/
/*##########################################################################################################*/
/*##########################################################################################################*/

//junk: my english is ssoooooo bad...
class parserCalc: public EvalFunction{ // "it must inherit from the eval" - so it inherits
public:
  mu::Parser  parser;
  string_type tmpFunction; // I need this!

  parserCalc(); //parser settings

  //void writeExpression();
  void operator()(Specimen &argument);
  void writeExpression(string_type expression);
  //void setVariables(int howMany); //it has to be from keyboard - no need of determine the number of variables
  //void setVariables(const long double korosu); //not now
  float evalExpression();
};

class variableCalc: public ScalingFunction{
public:
      mu::Parser  parser;
      string_type tmpFunction; // I need this!

      variableCalc(); //parser settings

      void writeExpression(string_type expression);
      Gene operator()(const Gene &value);
      float evalExpression();
    };

#endif
